package be.weavnet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class HelloServlet
 */
public class HelloServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		SimpleDateFormat dateFormat =  new SimpleDateFormat("EEEEE dd MMMMM YYYY");
		SimpleDateFormat timeformat = new SimpleDateFormat("hh:mm") ;
		Date now = new Date();
		
		String text = "";
		String formatedDate = dateFormat.format(now);
		String formateTime = timeformat.format(now);
		String username = request.getParameter("username");
		
		if (username == null || username.isEmpty() )
			{ 
			 username = "world";
			
			
		}
		
		
		
		PrintWriter out = response.getWriter() ;
		out.println (" <html> <head><title></title> hello Servlet </tile></head></html>");
		out.println (" <body> <h1> bonjour " + username +"  </h1> ");
		
		
		out.println (" <p> nous somme le " + formatedDate + "</p>");
		
		out.println (" <p> il est  " + formateTime + "</p>");
		
		out.println (" </body>  </html>");		
		
	}
		
		/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet (request, response);
	}

}

		
		
			
		
		

	